<?php
$options = getopt('k:d:i:');
require_once 'DAO/Links.php';
$dao = new DAO_Links();
if (!empty($options['i']) && $options['i'] == 'mportant') {
    $keywords = explode(',', $options['k']);
    $data = $dao->getDevelopersForKeywords($keywords, true);
} elseif (!empty($options['k']) && empty($options['d'])) {
    $keywords = explode(',', $options['k']);
    $data = $dao->getDevelopersForKeywords($keywords);
} elseif (!empty($options['k']) && !empty($options['d'])) {
    $developer = $options['d'];
    $keywords = explode(',', $options['k']);
    $data = $dao->getSpecificDeveloperKeywordAssociations($developer, $keywords);
} else {
    $data = $dao->getDevelopersByImportance();
}
echo "+---------------------------+---------------------------+\n";
echo "| Developer                 | Associations              |\n";
echo "+---------------------------+---------------------------+\n";
foreach ($data as $line) {
    echo '| ';
    echo substr("{$line['name']}                         ", 0, 25);
    echo ' | ';
    echo substr("{$line['associations']}                         ", 0, 25);
    echo " |\n";
}
echo "+---------------------------+---------------------------+\n";
